Skip to content

feat: add pinocchio counter example with compressible PDA#21

Open
tilo-14 wants to merge 3 commits intomainfrom
feat/pinocchio-counter
Open

feat: add pinocchio counter example with compressible PDA#21
tilo-14 wants to merge 3 commits intomainfrom
feat/pinocchio-counter

Conversation

@tilo-14
Copy link
Contributor

@tilo-14 tilo-14 commented Feb 12, 2026

Summary

  • Adds a minimal Pinocchio + Light Protocol counter program at pinocchio/counter/
  • Demonstrates rent-free compressible PDA accounts without Anchor dependency
  • Serves as the simple counterpart to the existing complex pinocchio/swap/ example

What's included

Program (14 files):

  • create_counter instruction — creates counter PDA, registers with Light Protocol for compression via prepare_compressed_account_on_init + CPI
  • increment instruction — pure on-chain owner-gated mutation, no Light CPI needed
  • CounterState struct with CompressionInfo, owner, count (bytemuck zero-copy)
  • Auto-generated compress/decompress/config handlers via #[derive(LightProgramPinocchio)]

Tests:

  • CounterSdk implementing LightProgramInterface for decompression
  • Full lifecycle test: create → increment → auto-compress → decompress → verify state → increment again

Key design decisions

Decision Choice Rationale
CPI context CpiAccountsConfig::new Single PDA, no batching needed
CompressionInfo Bare (not Option) bytemuck Pod requires it
No close instruction Omitted Compression handles rent recovery
Discriminators Anchor-compatible sha256 Consistent with swap example

Test plan

  • cargo check -p pinocchio-counter compiles
  • cargo check --tests -p pinocchio-counter compiles
  • Integration test passes with Light Protocol test infra

Open with Devin

Minimal Pinocchio + Light Protocol counter program demonstrating
rent-free compressible accounts without Anchor dependency.

Two instructions: create_counter (PDA init + Light CPI registration)
and increment (pure on-chain owner-gated mutation). Full lifecycle
test covers create, increment, auto-compress, decompress, and
post-decompression increment.
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 7 additional findings.

Open in Devin Review

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 11 additional findings in Devin Review.

Open in Devin Review

Comment on lines +7 to +8
"@lightprotocol/compressed-token": "file:../../light-protocol/js/compressed-token",
"@lightprotocol/stateless.js": "file:../../light-protocol/js/stateless.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Dependencies changed from published packages to local file paths, breaking builds for all other developers

The typescript-client/package.json replaces published beta registry packages with local file: paths pointing to ../../light-protocol/js/.... This is a developer-local change that was accidentally committed.

Root Cause and Impact

The original dependencies:

"@lightprotocol/compressed-token": "beta",
"@lightprotocol/stateless.js": "beta",

were changed to:

"@lightprotocol/compressed-token": "file:../../light-protocol/js/compressed-token",
"@lightprotocol/stateless.js": "file:../../light-protocol/js/stateless.js",

These file: paths reference a sibling light-protocol repository that only exists on the original developer's machine. Any other developer running npm install in typescript-client/ will get an error because ../../light-protocol/js/compressed-token does not exist on their filesystem. This effectively breaks the entire typescript-client package for everyone else.

Suggested change
"@lightprotocol/compressed-token": "file:../../light-protocol/js/compressed-token",
"@lightprotocol/stateless.js": "file:../../light-protocol/js/stateless.js",
"@lightprotocol/compressed-token": "beta",
"@lightprotocol/stateless.js": "beta",
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant